package dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class BaseDao {
private final static String STR ="com.mysql.jdbc.Driver";
private final static String URL ="jdbc:mysql://127.0.0.1:3306/test";
private final static String NAME ="root";
private final static String PASS ="123456";

public Connection getConnection(){
	Connection con = null;
	try {
		Class.forName(STR);
		con = DriverManager.getConnection(URL,NAME,PASS);
		return con != null ? con : null;
	} catch (SQLException e) {
		e.printStackTrace();
	} catch (ClassNotFoundException e) {
		e.printStackTrace();
	}
	return con;
}
public static void main(String[] args) {
	BaseDao dao =new BaseDao();
	Connection con = null;
	con=dao.getConnection();
	if (con!=null) {
		System.out.println("ok");
	}
}
}
